$(function () {
    //发布项目
    $('#addProject-bc').on('click', function () {
        var file = document.getElementById('Enclosure');
        var fileobj = file.files['0'];
        var form = new FormData();
        form.append('pName', document.getElementById('pName').value);
        form.append('pChar', document.getElementById('pChar').value);
        form.append('teacher', document.getElementById('teacher').value);
        form.append('pDesc', document.getElementById('pDesc').value);
        form.append('pRank', document.getElementById('pRank').value);
        form.append('Enclosure', fileobj);
        $.ajax({
            type: "POST",
            url: "declarePro.php",
            async: false,
            dataType: "json",
            data: form,
            cache: false,
            processData: false,
            contentType: false,
            success: function (msg) {
                if (msg.status == "1") {
                    alert(msg.mes);
                    location.href = "owner-myProject.php";
                } else if (msg.status == "-1") {
                    alert(msg.mes);
                    window.location.reload();
                }
            },
            // error: function (XMLHttpRequest, textStatus, errorThrown) {
            //     alert(XMLHttpRequest.readyState);
            //     alert(textStatus);
            // }
        });
    });

    //修改密码
    $('#userPas-bc').on('click',function () {
        $.ajax({
            type: 'POST',
            url: 'changePass.php',
            async: false,
            dataType: "json",
            data: $('#userPas').serialize(),
            success: function (msg) {
                if (msg.status == "1") {
                    alert(msg.mes);
                    location.href = "owner-myProject.php";
                }
                else if (msg.status == "-1") {
                    alert(msg.mes);
                    window.location.reload();
                }
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(XMLHttpRequest.readyState);
                alert(textStatus);
            }

        });
    });
    //注销
    $('#zx').on('click',function () {
        if(window.confirm("确定退出吗？")){
            location.href='login.html';
        }
    });
});